Telegram Group & Telegram Channel
📊 Своя метрика в Prometheus

Хотите отслеживать, сколько запросов прилетает в ваше приложение? Или сколько задач выполнилось? Делается это за 5 шагов — через кастомные метрики.

Попробуем реализовать пример: считаем количество HTTP-запросов в приложении на Go.

1. Подключаем библиотеку Prometheus:
go get github.com/prometheus/client_golang/prometheus


2. Создаём счётчик:
var requestCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "myapp_http_requests_total",
Help: "Total number of HTTP requests",
})


3. Регистрируем метрику:
func init() {
prometheus.MustRegister(requestCounter)
}


requestCounter будет инкрементироваться при запросе приложения.

4. Добавляем endpoint для Prometheus:
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8080", nil))


5. Пишем конфиг на стороне Prometheus
scrape_configs:
- job_name: 'myapp'
metrics_path: /metrics
static_configs:
- targets: ['localhost:8080']


📍 Всё — теперь http://localhost:8080/metrics отдаёт данные, которые можно добавить в дашборд в Prometheus.

🐸Библиотека devops'a #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/devopsslib/3737
Create:
Last Update:

📊 Своя метрика в Prometheus

Хотите отслеживать, сколько запросов прилетает в ваше приложение? Или сколько задач выполнилось? Делается это за 5 шагов — через кастомные метрики.

Попробуем реализовать пример: считаем количество HTTP-запросов в приложении на Go.

1. Подключаем библиотеку Prometheus:

go get github.com/prometheus/client_golang/prometheus


2. Создаём счётчик:
var requestCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "myapp_http_requests_total",
Help: "Total number of HTTP requests",
})


3. Регистрируем метрику:
func init() {
prometheus.MustRegister(requestCounter)
}


requestCounter будет инкрементироваться при запросе приложения.

4. Добавляем endpoint для Prometheus:
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8080", nil))


5. Пишем конфиг на стороне Prometheus
scrape_configs:
- job_name: 'myapp'
metrics_path: /metrics
static_configs:
- targets: ['localhost:8080']


📍 Всё — теперь http://localhost:8080/metrics отдаёт данные, которые можно добавить в дашборд в Prometheus.

🐸Библиотека devops'a #буст

BY Библиотека девопса | DevOps, SRE, Sysadmin




Share with your friend now:
tg-me.com/devopsslib/3737

View MORE
Open in Telegram


Библиотека девопса | DevOps SRE Sysadmin Telegram | DID YOU KNOW?

Date: |

That growth environment will include rising inflation and interest rates. Those upward shifts naturally accompany healthy growth periods as the demand for resources, products and services rise. Importantly, the Federal Reserve has laid out the rationale for not interfering with that natural growth transition.It's not exactly a fad, but there is a widespread willingness to pay up for a growth story. Classic fundamental analysis takes a back seat. Even negative earnings are ignored. In fact, positive earnings seem to be a limiting measure, producing the question, "Is that all you've got?" The preference is a vision of untold riches when the exciting story plays out as expected.

Unlimited members in Telegram group now

Telegram has made it easier for its users to communicate, as it has introduced a feature that allows more than 200,000 users in a group chat. However, if the users in a group chat move past 200,000, it changes into "Broadcast Group", but the feature comes with a restriction. Groups with close to 200k members can be converted to a Broadcast Group that allows unlimited members. Only admins can post in Broadcast Groups, but everyone can read along and participate in group Voice Chats," Telegram added.

Библиотека девопса | DevOps SRE Sysadmin from id


Telegram Библиотека девопса | DevOps, SRE, Sysadmin
FROM USA